|
Code location |
Code |
Model object |
Details |
|
1 |
/*
|
|
Nonfunctional code (Comment) |
|
2 |
* File: attitude_controller.c
|
|
Nonfunctional code (Comment) |
|
3 |
*
|
|
Nonfunctional code (Comment) |
|
4 |
* Code generated for Simulink model 'attitude_controller'.
|
|
Nonfunctional code (Comment) |
|
5 |
*
|
|
Nonfunctional code (Comment) |
|
6 |
* Model version : 1.67
|
|
Nonfunctional code (Comment) |
|
7 |
* Simulink Coder version : 8.5 (R2013b) 08-Aug-2013
|
|
Nonfunctional code (Comment) |
|
8 |
* C/C++ source code generated on : Mon Feb 03 08:13:29 2014
|
|
Nonfunctional code (Comment) |
|
9 |
*
|
|
Nonfunctional code (Comment) |
|
10 |
* Target selection: ert.tlc
|
|
Nonfunctional code (Comment) |
|
11 |
* Embedded hardware selection: 32-bit Embedded Processor
|
|
Nonfunctional code (Comment) |
|
12 |
* Code generation objectives: Unspecified
|
|
Nonfunctional code (Comment) |
|
13 |
* Validation result: Not run
|
|
Nonfunctional code (Comment) |
|
14 |
*/
|
|
Nonfunctional code (Comment) |
|
15 |
|
|
Nonfunctional code (Empty line) |
|
16 |
#include "attitude_controller.h"
|
|
Not processed (Include statement) |
|
17 |
#include "attitude_controller_private.h"
|
|
Not processed (Include statement) |
|
18 |
|
|
Nonfunctional code (Empty line) |
|
19 |
/* Output and update for referenced model: 'attitude_controller' */
|
|
Nonfunctional code (Comment) |
|
20 |
void attitude_controller(const real_T *rtu_Disp_Cmd, const real_T *rtu_Disp_FB,
... |
|
- |
|
21 |
const real_T *rtu_Rate_FB, const boolean_T *rtu_Engaged, real_T *rty_Surf_Cmd,... |
|
- |
|
22 |
rtDW_attitude_controller *localDW, real_T rtp_dispGain, real_T rtp_dispLim,
|
|
- |
|
23 |
real_T rtp_rateGain, real_T rtp_rateLim, real_T rtp_intGain, real_T rtp_intLim... |
|
- |
|
24 |
real_T rtp_cmdLim)
|
|
- |
|
25 |
{
|
|
Nonfunctional code (Start of code segment) |
|
26 |
boolean_T rtb_Notengaged;
|
|
Local variable declaration |
|
27 |
real_T rtb_Sum2;
|
|
Local variable declaration |
|
28 |
real_T rtb_Sum1;
|
|
Local variable declaration |
|
29 |
real_T y;
|
|
Local variable declaration |
|
30 |
|
|
Nonfunctional code (Empty line) |
|
31 |
/* Logic: '<Root>/Not engaged' */
|
|
Nonfunctional code (Comment) |
|
32 |
rtb_Notengaged = !(*rtu_Engaged);
|
|
- |
|
33 |
|
|
Nonfunctional code (Empty line) |
|
34 |
/* UnitDelay: '<S2>/X' */
|
|
Nonfunctional code (Comment) |
|
35 |
rtb_Sum2 = localDW->X_DSTATE;
|
|
- |
|
36 |
|
|
Nonfunctional code (Empty line) |
|
37 |
/* Switch: '<S2>/Switch' incorporates:
|
|
Nonfunctional code (Comment) |
|
38 |
* Constant: '<S2>/Constant2'
|
|
Nonfunctional code (Comment) |
|
39 |
*/
|
|
Nonfunctional code (Comment) |
|
40 |
if (rtb_Notengaged) {
|
|
- |
|
41 |
rtb_Sum2 = 0.0;
|
|
- |
|
42 |
}
|
|
Nonfunctional code (End of code segment) |
|
43 |
|
|
Nonfunctional code (Empty line) |
|
44 |
/* End of Switch: '<S2>/Switch' */
|
|
Nonfunctional code (Comment) |
|
45 |
|
|
Nonfunctional code (Empty line) |
|
46 |
/* Saturate: '<S2>/Saturation' */
|
|
Nonfunctional code (Comment) |
|
47 |
if (rtb_Sum2 >= rtp_intLim) {
|
|
- |
|
48 |
rtb_Sum2 = rtp_intLim;
|
|
- |
|
49 |
} else {
|
|
- |
|
50 |
if (rtb_Sum2 <= (-rtp_intLim)) {
|
|
- |
|
51 |
rtb_Sum2 = -rtp_intLim;
|
|
- |
|
52 |
}
|
|
Nonfunctional code (End of code segment) |
|
53 |
}
|
|
Nonfunctional code (End of code segment) |
|
54 |
|
|
Nonfunctional code (Empty line) |
|
55 |
/* End of Saturate: '<S2>/Saturation' */
|
|
Nonfunctional code (Comment) |
|
56 |
|
|
Nonfunctional code (Empty line) |
|
57 |
/* Saturate: '<Root>/Disp Limit' */
|
|
Nonfunctional code (Comment) |
|
58 |
if ((*rtu_Disp_Cmd) >= rtp_dispLim) {
|
|
- |
|
59 |
y = rtp_dispLim;
|
|
- |
|
60 |
} else if ((*rtu_Disp_Cmd) <= (-rtp_dispLim)) {
|
|
- |
|
61 |
y = -rtp_dispLim;
|
|
- |
|
62 |
} else {
|
|
- |
|
63 |
y = *rtu_Disp_Cmd;
|
|
- |
|
64 |
}
|
|
Nonfunctional code (End of code segment) |
|
65 |
|
|
Nonfunctional code (Empty line) |
|
66 |
/* Gain: '<Root>/Disp Gain' incorporates:
|
|
Nonfunctional code (Comment) |
|
67 |
* Saturate: '<Root>/Disp Limit'
|
|
Nonfunctional code (Comment) |
|
68 |
* Sum: '<Root>/Sum'
|
|
Nonfunctional code (Comment) |
|
69 |
*/
|
|
Nonfunctional code (Comment) |
|
70 |
y = rtp_dispGain * (y - (*rtu_Disp_FB));
|
|
- |
|
71 |
|
|
Nonfunctional code (Empty line) |
|
72 |
/* Saturate: '<Root>/Rate Limit' */
|
|
Nonfunctional code (Comment) |
|
73 |
if (y >= rtp_rateLim) {
|
|
- |
|
74 |
y = rtp_rateLim;
|
|
- |
|
75 |
} else {
|
|
- |
|
76 |
if (y <= (-rtp_rateLim)) {
|
|
- |
|
77 |
y = -rtp_rateLim;
|
|
- |
|
78 |
}
|
|
Nonfunctional code (End of code segment) |
|
79 |
}
|
|
Nonfunctional code (End of code segment) |
|
80 |
|
|
Nonfunctional code (Empty line) |
|
81 |
/* Sum: '<Root>/Sum1' incorporates:
|
|
Nonfunctional code (Comment) |
|
82 |
* Saturate: '<Root>/Rate Limit'
|
|
Nonfunctional code (Comment) |
|
83 |
*/
|
|
Nonfunctional code (Comment) |
|
84 |
rtb_Sum1 = y - (*rtu_Rate_FB);
|
|
- |
|
85 |
|
|
Nonfunctional code (Empty line) |
|
86 |
/* Sum: '<Root>/Sum2' incorporates:
|
|
Nonfunctional code (Comment) |
|
87 |
* Gain: '<Root>/Rate Gain'
|
|
Nonfunctional code (Comment) |
|
88 |
*/
|
|
Nonfunctional code (Comment) |
|
89 |
y = rtb_Sum2 + (rtp_rateGain * rtb_Sum1);
|
|
- |
|
90 |
|
|
Nonfunctional code (Empty line) |
|
91 |
/* Saturate: '<Root>/Cmd Limit' */
|
|
Nonfunctional code (Comment) |
|
92 |
if (y >= rtp_cmdLim) {
|
|
- |
|
93 |
*rty_Surf_Cmd = rtp_cmdLim;
|
|
- |
|
94 |
} else if (y <= (-rtp_cmdLim)) {
|
|
- |
|
95 |
*rty_Surf_Cmd = -rtp_cmdLim;
|
|
- |
|
96 |
} else {
|
|
- |
|
97 |
*rty_Surf_Cmd = y;
|
|
- |
|
98 |
}
|
|
Nonfunctional code (End of code segment) |
|
99 |
|
|
Nonfunctional code (Empty line) |
|
100 |
/* End of Saturate: '<Root>/Cmd Limit' */
|
|
Nonfunctional code (Comment) |
|
101 |
|
|
Nonfunctional code (Empty line) |
|
102 |
/* Switch: '<S2>/Switch1' */
|
|
Nonfunctional code (Comment) |
|
103 |
if (rtb_Notengaged) {
|
|
- |
|
104 |
/* Update for UnitDelay: '<S2>/X' incorporates:
|
|
Nonfunctional code (Comment) |
|
105 |
* Constant: '<S2>/Constant2'
|
|
Nonfunctional code (Comment) |
|
106 |
*/
|
|
Nonfunctional code (Comment) |
|
107 |
localDW->X_DSTATE = 0.0;
|
|
- |
|
108 |
} else {
|
|
- |
|
109 |
/* Update for UnitDelay: '<S2>/X' incorporates:
|
|
Nonfunctional code (Comment) |
|
110 |
* Gain: '<Root>/Int Gain'
|
|
Nonfunctional code (Comment) |
|
111 |
* Product: '<S2>/Product1'
|
|
Nonfunctional code (Comment) |
|
112 |
* Sum: '<S2>/Sum'
|
|
Nonfunctional code (Comment) |
|
113 |
*/
|
|
Nonfunctional code (Comment) |
|
114 |
localDW->X_DSTATE = (attitude_controller_ConstB.Product * (rtp_intGain *
|
|
- |
|
115 |
rtb_Sum1)) + rtb_Sum2;
|
|
- |
|
116 |
}
|
|
Nonfunctional code (End of code segment) |
|
117 |
|
|
Nonfunctional code (Empty line) |
|
118 |
/* End of Switch: '<S2>/Switch1' */
|
|
Nonfunctional code (Comment) |
|
119 |
}
|
|
Nonfunctional code (End of code segment) |
|
120 |
|
|
Nonfunctional code (Empty line) |
|
121 |
/* Model initialize function */
|
|
Nonfunctional code (Comment) |
|
122 |
void attitude_controller_initialize(rtDW_attitude_controller *localDW)
|
|
- |
|
123 |
{
|
|
Nonfunctional code (Start of code segment) |
|
124 |
/* Registration code */
|
|
Nonfunctional code (Comment) |
|
125 |
|
|
Nonfunctional code (Empty line) |
|
126 |
/* states (dwork) */
|
|
Nonfunctional code (Comment) |
|
127 |
(void) memset((void *)localDW, 0,
|
|
- |
|
128 |
sizeof(rtDW_attitude_controller));
|
|
- |
|
129 |
}
|
|
Nonfunctional code (End of code segment) |
|
130 |
|
|
Nonfunctional code (Empty line) |
|
131 |
/*
|
|
Nonfunctional code (Comment) |
|
132 |
* File trailer for generated code.
|
|
Nonfunctional code (Comment) |
|
133 |
*
|
|
Nonfunctional code (Comment) |
|
134 |
* [EOF]
|
|
Nonfunctional code (Comment) |
|
135 |
*/
|
|
Nonfunctional code (Comment) |